/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package binh;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author ADMIN
 */
public class CLoopers
{
    private static CLoopers _Instance =  new CLoopers();    
    
    public static CLoopers Instance(){       
        return _Instance;
        
    }
    
    private List<ILoopable> LooperList;
    
    private CLoopers()
    {
        LooperList = new ArrayList<ILoopable>();
    }
    
    public void AddLooper(ILoopable Looper){
        LooperList.add(Looper);
    }

    public void StartLoop()
    {
        Timer timer = new Timer("Game Loop Thread");
        timer.schedule(new TimerTask(){

            @Override
            public void run()
            {
                for (ILoopable looper : LooperList)
                {
                    looper.OnTimer(1000);
                }
            }
        }, 0, 1000);
    }
}
